<template>
    <div>  
        <div id="slider" class="mui-slider">
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted" data-scroll="1">
                <div class="mui-scroll" style="transform: translate3d(0px, 0px, 0px) translateZ(0px); transition-duration: 0ms; transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1);">
                    <a :class="['mui-control-item', item.id===0?'mui-active':'']" v-for="item in photoList" :key="item.id" @tap="getPhoto(item.id)">
                        {{item.title}}
                    </a>
                </div>
            </div>
        </div>
        <ul class="photo-list">
            <router-link v-for="item in photos" :key="item.img_url" :to="'/home/photoInfo/'+item.id" tag="li">
                <img v-lazy="item.img_url">
                <div class="info">
                    <div class="info_title">{{item.title}}</div>
                    <div class="info_body">{{item.zhaiyao}}</div>
                </div>
            </router-link>
        </ul> 
    </div> 
</template>

<script> 
import mui from '../../lib/mui/js/mui.min.js'; 
 
export default {
    data(){
        return {
            photoList:[],
            photos:[]
        }
    },
    created(){
        this.getPhotoList();
        this.getPhoto(0);
    },
    mounted(){
       mui('.mui-scroll-wrapper').scroll({
            deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
        });
    },
    methods:{
        getPhotoList(){
            this.$http.get("photo/photo.json").then(result=>{
                if(result.body.status===0){
                    result.body.message.unshift({title:"全部",id:0})
                    this.photoList = result.body.message;
                }
            })
        },
        getPhoto(photoId){
            console.log(photoId+"---------------");
            this.$http.get("photo/"+photoId+".json").then(result=>{
                if(result.body.status===0){
                    this.photos = result.body.message;
                }
            })
        }
    }
}
</script>
<style scoped>
    .mui-slider{
        touch-action: pan-y; 
    }
    .photo-list{
        list-style: none;
        margin: 0;
        padding: 10px 10px 0 10px;
    }
    .photo-list>li{
        background-color: #ccc;
        margin-bottom: 10px;
        text-align: center;
        box-shadow: 0 0 9px #999;
        position: relative;
    }
    .photo-list img{
        width: 100%;
        vertical-align: middle;
    }
    .photo-list img[lazy=loading]{
        width: 40px;
        height: 300px;
        margin: auto;
    } 
    .photo-list .info{
        max-height: 84px;
        color: white;
        text-align: left;
        width:100%;
        position: absolute;
        bottom: 0;
        background-color: rgba(0,0,0,0.4);
    }
    .photo-list .info>.info_title{
        font-size: 14px;
    }
    .photo-list .info>.info_body{
        font-size: 12px;
    }
</style>
